package com.yao.club.controller;

import com.yao.club.entity.result.ResponseEntity;
import com.yao.club.entity.dto.PostsTipOff;
import com.yao.club.entity.request.PostsTipOffRequestEntity;
import com.yao.club.service.PostsTipOffService;
import com.yao.club.service.UserService;
import com.yao.club.token.PassToken;
import com.yao.club.token.UserToken;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController
@RequestMapping("/app/tipOff")
@Api(value = "俱乐部帖子-举报接口", description = "俱乐部帖子-举报接口服务", tags = "俱乐部帖子-举报接口模块")
public class PostsTipOffController {

    @Autowired
    UserService userService;

    @Autowired
    PostsTipOffService postsTipOffService;

    @Resource
    HttpServletRequest request;


    @PassToken
    @ApiOperation(value = "获得帖子举报列表", notes = "获得帖子举报列表", httpMethod = "GET")
    @GetMapping("/list")
    public ResponseEntity<List<PostsTipOff>> list(){
        return postsTipOffService.list();
    }
    //https://iovapicyclone.zonsenmotor.com/club-moto/app/tipOff/save

    @UserToken
    @ApiOperation(value = "举报帖子", notes = "举报帖子", httpMethod = "POST")
    @PostMapping("/save")
    public ResponseEntity<Boolean> save(PostsTipOffRequestEntity clubTipOffRequestEntity){
        String username = (String) request.getAttribute("username");
        return postsTipOffService.save(clubTipOffRequestEntity,username);
    }


}
